## DESCRIPTION
## Parametric equations: parametric curve in space
## ENDDESCRIPTION

## KEYWORDS('parametric', 'curve in space')

## DBsubject('WeBWorK')
## DBchapter('WeBWorK Tutorial')
## DBsection('Fort Lewis Tutorial 2011')
## Date('01/30/2011')
## Author('Paul Pearson')
## Institution('Fort Lewis College')
## TitleText1('')
## EditionText1('')
## AuthorText1('')
## Section1('')
## Problem1('')


#################################
#  Initialization

DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"parserVectorUtils.pl",
"AnswerFormatHelp.pl",
);

TEXT(beginproblem());


#################################
#  Setup

Context("Vector2D");
#Context("Vector"); # for 3D vectors
Context()->variables->are(t=>"Real");
Context()->variables->set(t=>{limits=>[0,5]});
Context()->flags->set( ijk=>0 );

$answer = Vector("<2t,(2t)^2>");

#####################################
#  Main text

Context()->texStrings;
BEGIN_TEXT
Find a vector parametric function \( \vec{r}(t) \) 
for a bug that moves along the parabola \( y = x^2 \) 
with velocity \( \vec{v}(t) = \langle 2, 8t \rangle \) 
for all \( t \).
$BR
$BR
\( \vec{r}(t) = \) 
\{ ans_rule(20) \}
\{ AnswerFormatHelp("vectors") \} 
END_TEXT
Context()->normalStrings;


############################
#  Answer evaluation

$showPartialCorrectAnswers = 1;

sub components {

  my $V = shift;
  $V = $V->perl;

  if ( $V =~ m/Value/ ) {

    $V =~ s/Value::Vector->new~~(//g;
    $V = substr($V, 0, -1);
    $V =~ s/Value::Real->new//g;
    $V =~ s/~~$//g;
    $V =~ s/ //g;
    return split(',',$V);

  } else {

    $V =~ s/~~* i~~)/~~),/g;
    $V =~ s/~~* j~~)/~~),/g;
    $V =~ s/~~* k~~)/~~),/g;
    $V =~ s/~~$//g;
    $V =~ s/ //g;
    $V = substr($V, 0, -1);
    return split(',',$V);

  }

}


sub mycheck {
  my ($correct, $student, $ansHash) = @_;
  my @r = components($student);
  my $xstu = Formula("$r[0]");
  my $ystu = Formula("$r[1]");
  if ( ($xstu->D('t')==Formula("2")) &&
       ($ystu->D('t')==Formula("8t")) )
  { return 1; } else { return 0; } 
}

ANS( $answer->cmp( checker=>~~&mycheck ) );


############################
#  Solution

Context()->texStrings;
BEGIN_SOLUTION
${PAR}SOLUTION:${PAR}
Solution explanation goes here.
END_SOLUTION
Context()->normalStrings;

COMMENT('MathObject version.');

ENDDOCUMENT(); 